
2
2
.
.
2
2
.
.
1
1
L
L
i
i
t
t
e
e
r
r
a
a
l
l
s
s
Literal is string representation of both data type and data value: 10, "John", ["AUDI", "FIAT"]
Literal notations are different ways of constructing literals that represent the same data type: 10, +10, 012 or 0xA.
Literal types
Represents null data type with value
Represents boolean data type and value
Represents integer data type and value
Represents floating point data type and value
Represents string data type and value
Represents string data type and value
Nil literal represents Nil Data Type and it is written by using case sensitive nil.
var age : Int? = nil
Boolean literal represents Boolean Data Type and value and it is written by using case sensitive true or false.
var access1 = true
var access2 : Bool = false
Integer literal can represent Signed and Unsigned Integer Data Types and supports multiple notations.
var age = -41 //Decimal notation (base 10).
age = -0b101001 //Binary notation (base 2 ).
age = -0o51 //Octal notation (base 8 ).
age = -0x29 //Hexadecimal notation (base 16).
Float literal can represents Float and Double Data Types and value and supports two notations.
var temp = 123.045 //Normal notation.
temp = 1.23045E+2 //Scientific notation.